package org.jsola.hr.constant.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 【社保回款计划回款状态】excel导入导出时字段值转换
 *
 * @author zhuhaoran
 */
public class BackStatusConverter implements Converter<String> {


    private final Map<String, String> javaToConvert = new HashMap<String, String>(8) {{
        put("1", "未回款");
        put("2", "部分回款");
        put("3", "已回款");
    }};

    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData<String> convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String valueStr = javaToConvert.get(value);
        return StringUtils.isEmpty(valueStr) ? new CellData<>() : new CellData<>(valueStr);
    }
}
